STEP 13: Now that we have random coordinates and a random image label, we can make a sprite!

When using nested loops, the inside loop completes all of its iterations for each iteration of the outside loop.

  • Go to GRAPHICS and . Drag Sprite at Position indented two times inside the for loop.
  • Change "codester" to rand_image and set the x and y arguments to be rand_x and rand_y.

The range(10) loop makes 10 trash sprites randomly for each new level that starts when the while loop repeats.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)